<template>
	<view class="expand_box">
		<view class="expand_item">
			<view class="title_box flex_ac_js">
				<view class="title">英语短文</view>
				<view class="more flex_ac" @tap="goToPage('/pages/expands/readMore/readMore?type=0')">
					<text>更多</text>
					<image src="@/static/images/icon/right.svg"></image>
				</view>
			</view>
			<view class="content_1 content" v-for="item in articleList" :key="item.id" @tap="goToPage('/pages/expands/readDetails/readDetails?id=' + item.id + '&type=0')">
				<view class="image">
					<image :src="item.picture"></image>
				</view>
				<view class="title">{{ item.titleUk }}</view>
				<view class="text">{{ item.content }}</view>
			</view>
		</view>
		
		<view class="expand_item">
			<view class="title_box flex_ac_js">
				<view class="title">英语视频</view>
				<view class="more flex_ac" @tap="goToPage('/pages/expands/readMore/readMore?type=1')">
					<text>更多</text>
					<image src="@/static/images/icon/right.svg"></image>
				</view>
			</view>
			<view class="content_2 content">
				<view class="content_item flex_js" v-for="item in videoList" :key="item.id" @tap="goToPage('/pages/expands/readDetails/readDetails?id=' + item.id + '&type=1')">
					<view class="image">
						<image :src="item.homepage"></image>
					</view>
					<view class="" style="width: calc(100% - 200rpx);">
						<view class="title">{{ item.title }}</view>
						<view class="text" style="margin-top: 20rpx;">{{ item.caption }}</view>
					</view>
				</view>
			</view>
		</view>
		
		<view class="expand_item">
			<view class="title_box flex_ac_js">
				<view class="title">英语绘本</view>
				<view class="more flex_ac" @tap="goToPage('/pages/expands/readMore/readMore?type=2')">
					<text>更多</text>
					<image src="@/static/images/icon/right.svg"></image>
				</view>
			</view>
			<view class="content_3 flex_ac">
				<view class="content_item" v-for="item in pictureBookList" :key="item.id" @tap="goToPage('/pages/expands/readDetails/readDetails?id=' + item.id + '&type=2')">
					<view class="image">
						<image :src="item.homepage"></image>
					</view>
					<view class="title">{{ item.title }}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { listArticle, listVideo, listPictureBook } from '@/api/expands/readMore/readMore.js';
	export default {
		data() {
			return {
				articleList: [],
				videoList: [],
				pictureBookList: []
			}
		},
		onLoad() {
			this.getArticle()
			this.getVideo()
			this.getPictureBook()
		},
		methods: {
			goToPage(url) {
				uni.navigateTo({
					url
				})
			},
			async getArticle() {
				const { data } = await listArticle()
				this.articleList = Array(data[0])
			},
			async getVideo() {
				const { data } = await listVideo()
				this.videoList = data
			},
			async getPictureBook() {
				const { data } = await listPictureBook()
				this.pictureBookList = data
			},
		}
	}
</script>

<style lang="scss" scoped>
.expand_box {
	height: 100vh;
	padding: 30rpx;
	background: $uni-bg-color-page;
	overflow: auto;
	
	.expand_item {
		margin-bottom: 50rpx;
		padding: 30rpx;
		background-color: $uni-bg-color;
		border-radius: 12rpx;
		
		.title_box {
			margin-bottom: 30rpx;
			
			.title {
				font-size: 40rpx;
			}
			.more {
				text {
					font-size: 24rpx;
					color: $uni-text-color-placeholder;
				}
				
				image {
					width: 28rpx;
					height: 28rpx;
				}
			}
		}
	
		.content_1 {
			.image image {
				width: 100%;
				height: 300rpx;
				border-radius: 10rpx;
			}
		}
		
		.content_2 {
			.content_item {
				border-bottom: 2rpx solid $uni-border-bottom-color;
				padding-bottom: 20rpx;
				margin-bottom: 30rpx;
				
				.image image {
					width: 180rpx;
					height: 180rpx;
					border-radius: 10rpx;
					margin-right: 20rpx;
				}
			}
		}
		
		.content_3 {
			.content_item {
				width: 33%;
				text-align: center;
				
				.image image {
					width: 150rpx;
					height: 150rpx;
					border-radius: 10rpx;
				}
				
				.title {
					font-size: 28rpx;
					color: $uni-text-color;
					margin-top: 8rpx;
				}
			}
		}
		
		.content {
			.title {
				margin-top: 10rpx;
				font-size: 28rpx;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2;
				overflow: hidden;
				text-overflow: ellipsis;
			}
			
			.text {
				margin-top: 8rpx;
				font-size: 24rpx;
				color: $uni-text-color-grey;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}
		}
	}
}
</style>
